<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Carbon\Carbon;
use App\Models\Store;
use App\Models\Report;

class EtcData extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'etc:data';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'ETC统计';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        ini_set('max_execution_time', '60'); 
        set_time_limit(0);
        echo time();
        $start = Carbon::yesterday()->timestamp;

        $end = Carbon::today()->timestamp;
        $etc_api = config('custom.etc_api_url');
        $etc_park = config('custom.etc_park');
        $bank_time = date("Y-m-d 00:00:00", $start);
        $all_fee = [];
        $resEtc = [];
        foreach ($etc_park as $p) {
            $data = curl_post($etc_api, ["park"=>$p,"date"=>$bank_time]);
            echo $bank_time;
            $data = json_decode($data, true);
            echo time();
            print_r($data); exit;
            if($data['error'] != "ok") continue;
            foreach ($data['data']['list'] as $val) {

            }
        }


        $this->info('ETC统计');
    }


}

